{% macro ReturnTop() %}

<!-- 返回顶部按钮 -->
<link rel="stylesheet" href="/css/macros/ReturnTop.css">

<div class="ReturnTop">
  <img src="/images/public/矢量图/返回顶部.svg" alt="">
</div>

<script src="/js/myJS/My_JS.js"></script>
<script>

  var ReturnTopTimer = null;

  window.onscroll = function () {
    if (ReturnTopTimer !== null) {
      clearTimeout(ReturnTopTimer);
    }
    ReturnTopTimer = setTimeout(() => {

      // 滚轮向下滑动返回顶部按钮就显示
      if (document.body.scrollTop > 0) {
        $(".ReturnTop").style.display = "block";
      }
      else {
        $(".ReturnTop").style.display = "none";
      }

      ReturnTopTimer = null;
    }, 120)
  }

  // 点击按钮页面返回顶部
  $(".ReturnTop").onclick = function () {
    document.body.scrollTop = 0;
  };

</script>

{% endmacro %}